n = int(input())
s = input()
for i in range(1,n):
count = sum([int(j) for j in s[:i]])
numbers = [s[:i]]
counter = 0
for j in s[i:]:
if counter + int(j) < count: counter += int(j)
elif counter + int(j) == count : counter = 0
else:
counter = 1
break
if counter == 0:
if s[i:].count("0") == len(s[i:]) and s.count("0") != len(s):
print("NO")
quit()
print("YES")
quit()
print("NO")
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n; cin>>n;
string s; cin>>s;
bool flag = false;
int sum = 0;
for(int i=0; i<n; i++)
{
sum += s[i]-'0';
if(i<n-1 && s[i] == '0') continue;
int rSum=0, j=i+1;
while(true)
{
while(j<n && (s[j]=='0' || rSum<sum)) rSum += s[j++]-'0';
if(rSum != sum) break;
else
{
if(j == n) flag = true;
rSum = 0;
if(flag) break;
}
}
}
cout<<(flag? "YES": "NO");
return 0;
}
43. Multiply Strings | 34. Find First and Last Position of Element in Sorted Array |
33. Search in Rotated Sorted Array | 17. Letter Combinations of a Phone Number |
5. Longest Palindromic Substring | 3. Longest Substring Without Repeating Characters |
1312. Minimum Insertion Steps to Make a String Palindrome | 1092. Shortest Common Supersequence |
1044. Longest Duplicate Substring | 1032. Stream of Characters |
987. Vertical Order Traversal of a Binary Tree | 952. Largest Component Size by Common Factor |
212. Word Search II | 174. Dungeon Game |
127. Word Ladder | 123. Best Time to Buy and Sell Stock III |
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |
60. Permutation Sequence | 42. Trapping Rain Water |
32. Longest Valid Parentheses | Cutting a material |
Bubble Sort | Number of triangles |
AND path in a binary tree | Factorial equations |
Removal of vertices | Happy segments |
Cyclic shifts | Zoos |